//首页v4_1版 注册验证

var index_reg_name_new = false;
var index_reg_email_new = false;
var index_reg_password_new = false;
var index_reg_rand_new = false;

function hasClass(ele,cls) {
  return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));
}
 
function addClass(ele,cls) {
  if (!this.hasClass(ele,cls)) ele.className += " "+cls;
}
 
function removeClass(ele,cls) {
  if (hasClass(ele,cls)) {
          var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)');
    ele.className=ele.className.replace(reg,' ');
  }
}
/*----------选项卡--------*/
function loginSinaSwitch(selfObj,boxObj){                   
	var lis=document.getElementById(selfObj).getElementsByTagName("li");
	for(var i=0,j=lis.length;i<j;i++){
		document.getElementById(boxObj+i).style.display="none";
		
		if(!!hasClass(lis[i],"cur")){
			document.getElementById(boxObj+i).style.display="block";
		}
		lis[i].onmousedown=function(){
			if(this.className=="cur"){
				return false;
			}
			else{
				thiSwitch(this);
			}
		}
	}
	function thiSwitch(obj){         //thiSwitch
		for(var i=0,j=lis.length;i<j;i++){
			if (lis[i]==obj){
				 addClass(lis[i],"cur");
				 document.getElementById(boxObj+i).style.display="block";
			}
			else{
				 removeClass(lis[i],"cur");
				 document.getElementById(boxObj+i).style.display="none";
			}
		}
	}
}
function showlogin(){
dialogBoxShadow();
document.getElementById("newlogin").style.display="block";
}
function closeShowMessage_sina(){
dialogBoxHidden();
document.getElementById("newlogin").style.display="none";
document.getElementById("bangding").style.display="none";
}
function closeShowMessage_first(){
dialogBoxHidden();
document.getElementById("newlogin").style.display="none";
}
function openss_back(){
 
//jQuery("#open").load("/jsp_cn/weibo/call.jsp?opt=1");
}
function openss(url){
	if(url==null || url==''){
		 window.open('/jsp_cn/weibo/call.jsp','new','height='+450+',,innerHeight='+450+',width='+550+',innerWidth='+550+',top='+200+',left='+200+',toolbar=no,menubar=no,scrollbars=auto,resizeable=no,location=no,status=no');
		return;
	}
  window.open('/jsp_cn/weibo/call.jsp?url='+url,'new','height='+450+',,innerHeight='+450+',width='+550+',innerWidth='+550+',top='+200+',left='+200+',toolbar=no,menubar=no,scrollbars=auto,resizeable=no,location=no,status=no');
//jQuery("#open").load("/jsp_cn/weibo/call.jsp?opt=1");
}

/************ 验证注册邮箱是否正确并存在 *********************/
function index_checkRegName_new(type){
	document.getElementById("showBlurUserName_new").className = "val dpb";
	var loginName = trim(document.getElementById("regloginname_new").value);
	var desc = '';
	
	
	if(loginName==''){
		desc = "用户名不能为空，请填写！";
	}
	var c = new RegExp();   
	c = /^[A-Za-z0-9_-]+$/;    
	if(!c.test(loginName)){
		desc = "用户名只支持英文 数字的组合，请正确填写!";
	}
	if(loginName.length>20){
		desc = "用户名的长度不能大于20!"
	}  
	if(loginName.toUpperCase().indexOf("DOCIN")>-1 || loginName.toUpperCase().indexOf("VONIBO")>-1 || loginName.toUpperCase().indexOf("BBS")>-1 ){
		desc = "该用户名已经存在，请重新输入！";
	}
	if(desc != ""){
		
			document.getElementById("showBlurUserName_new").src = "http://pics.wanlibo.com/images_cn/registration/reg_icon_cw.gif";
			document.getElementById("showBlurUserName_new").title = desc;
		
		return;
	}else{
		index_reg_name_new = true;
	}
	
	if(index_reg_name_new){
		//checkLoginDwr.checkLoginName(loginName,
			jQuery("#a5").load('/jsp_cn/jquery/login/reg_check.jsp?flag=name&loginName='+loginName,
			function (data){
				data = trim(data.replace(/\r\n/gim, "")); 
				if(data=="true"){
					
						document.getElementById("showBlurUserName_new").src = "http://pics.wanlibo.com/images_cn/registration/reg_zq.gif";
						document.getElementById("showBlurUserName_new").title = "";
					
				}else{
				
						document.getElementById("showBlurUserName_new").src = "http://pics.wanlibo.com/images_cn/registration/reg_icon_cw.gif";
						document.getElementById("showBlurUserName_new").title = "该用户名已经存在，请重新输入";
					
				}
			}
		);
	}
}
function index_checkRegEmail_new(type){
	document.getElementById("showBlurEmail_new").className = "val dpb";
	var loginEmail = document.getElementById("regloginemail_new").value;
	var desc='';
	if(loginEmail.indexOf(" ")>-1){
		desc='邮箱不能包含空格!';
	}else {
		loginEmail=trim(loginEmail);
		if(loginEmail==''){
			desc='请您输入邮箱!';
		}else if(!checkEmail(loginEmail)){
			desc='邮箱格式不正确,请重新输入';
		}else if (new RegExp("[,]","g").test(loginEmail)){
			desc='含有非法字符'
		}else if(loginEmail.length>100){
			desc='邮箱长度应小于100个字符';
		}
	}
	if(desc!=''){
		
			document.getElementById("showBlurEmail_new").src = "http://pics.wanlibo.com/images_cn/registration/reg_icon_cw.gif";
			document.getElementById("showBlurEmail_new").title = desc;
		
		return;
	}else{
		index_reg_email_new = true;
	}
	if(index_reg_email_new){
		loginEmail = trim(loginEmail);
		
		jQuery("#a5").load('/jsp_cn/jquery/login/reg_check.jsp?flag=email&loginEmail='+loginEmail,
			function (data){
				data = trim(data.replace(/\r\n/gim, "")); 
				if(data=="true"){
					
						document.getElementById("showBlurEmail_new").src = "http://pics.wanlibo.com/images_cn/registration/reg_zq.gif";
					
				}else{
					
						document.getElementById("showBlurEmail_new").src = "http://pics.wanlibo.com/images_cn/registration/reg_icon_cw.gif";
						document.getElementById("showBlurEmail_new").title = "该邮箱已经存在，请重新输入";
					
				}
			}
		);
		
		
	}
}
/************ 验证密码是否输入正确 *********************/
function index_checkRegPassword_new(type){
	document.getElementById("showBlurPwd_new").className = "val dpb";
	var v = document.getElementById("regpassword_new").value;
	var desc='';
	if(v.indexOf(" ")>-1){
		desc='密码不能包含空格';
	}else{
		v=trim(v);
		var c = new RegExp();   
		c = /^[A-Za-z0-9_-]+$/;  
		if(v==''){
			desc='请您输入密码';
		}else if(v.length<6){
			desc='密码长度不能小于6';
		}else if(v.length>16){
			desc='密码长度不能大于16';
		}else if(!c.test(v)){
			desc = "只支持英文 数字的组合，请正确填写!";
		}
	}
	if(desc!=''){
			document.getElementById("showBlurPwd_new").src = "http://pics.wanlibo.com/images_cn/registration/reg_icon_cw.gif";
			document.getElementById("showBlurPwd_new").title = desc;
		
		return;
	}else{
		
			document.getElementById("showBlurPwd_new").src = "http://pics.wanlibo.com/images_cn/registration/reg_zq.gif";
		index_reg_password_new=true;
		return;
	}
}
/************ 验证验证码 *********************/
function index_checkCode_new(){
	var code = trim(document.getElementById("yanzhengma_new").value);
	if(code==""){	alert("请输入验证码");	return;	}
	//checkLoginDwr.checkCode(code,index_showCheckCodeResult);
	jQuery("#a5").load('/jsp_cn/jquery/login/reg_check.jsp?flag=code&code='+code,index_showCheckCodeResult);
	
}
function index_showCheckCodeResult(data){
	data = trim(data.replace(/\r\n/gim,""));
	if(data=="true"){
		index_reg_rand_new = true;
		
	}else{
		alert("验证码输入错误，请重新输入");
		index_reg_rand_new = false;
		document.getElementById('yanzhengma_new').focus();
	}
}


function index_submit(){
	if(index_reg_name_new  && index_reg_email_new && index_reg_password_new && index_reg_rand_new ){
		return true;
	}else{
		return false;
	}
}
function refCode_new(){
	var d, s = "";
	var c = "";
	d = new Date();
	s += d.getYear()+c;
	s += (d.getMonth() + 1) + c;
	s += d.getDate() + c;
	s += d.getHours() + c;
	s += d.getMinutes() + c;
	s += d.getSeconds() + c;
	s += d.getMilliseconds();
	$('regimg_new').src="/servlet/getimg?"+s;
}
function setWb_News(){
	var num = "0";
	var obj = document.getElementsByName('change');
	for(i=0;i<obj.length;i++){
		if(obj[i].checked){
			num = "1";
			break;
		}
	}
	if(num == "0"){
		alert("至少选择一项操作");
		return;
	}else{
		submitWb_News();
	}
}
function submitWb_News(){
	var url = "/jsp_cn/weibo/update.jsp?time="+new Date().getTime();
	//var url = "/app/rr/aa?time="+new Date().getTime()+"&fn=setrr";

	if(document.getElementById("change_down").checked){
		url += "&cd=1";
	}
	if(document.getElementById("change_fav").checked){
		url += "&cf=1";
	}
	if(typeof(document.getElementById("change_bbs")) != 'undefined' && document.getElementById("change_bbs") != null && document.getElementById("change_bbs").checked){
		url += "&cb=1";
	}
	if(document.getElementById("change_message").checked){
		url += "&cm=1";
	}
	if(typeof(document.getElementById("change_doudan_fav")) != 'undefined' && document.getElementById("change_doudan_fav") != null && document.getElementById("change_doudan_fav").checked){
		url += "&cdf=1";
	}
	if(typeof(document.getElementById("change_doudan_top")) != 'undefined' && document.getElementById("change_doudan_top") != null && document.getElementById("change_doudan_top").checked){
		url += "&cdt=1";
	}
	jQuery("#setwb").load(url);
}
function setSD_News(){
	var num = "0";
	var obj = document.getElementsByName('change');
	for(i=0;i<obj.length;i++){
		if(obj[i].checked){
			num = "1";
			break;
		}
	}
	if(num == "0"){
		alert("至少选择一项操作");
		return;
	}else{
		submitSD_News();
	}
}
function submitSD_News(){
	var url = "/jsp_cn/shengda/update.jsp?time="+new Date().getTime();
	//var url = "/app/rr/aa?time="+new Date().getTime()+"&fn=setrr";

	if(document.getElementById("change_down").checked){
		url += "&cd=1";
	}
	if(document.getElementById("change_fav").checked){
		url += "&cf=1";
	}
	if(typeof(document.getElementById("change_bbs")) != 'undefined' && document.getElementById("change_bbs") != null && document.getElementById("change_bbs").checked){
		url += "&cb=1";
	}
	if(document.getElementById("change_message").checked){
		url += "&cm=1";
	}
	jQuery("#setwb").load(url);
}
function jiechu(){
	jQuery("#jiechuwb").load("/jsp_cn/weibo/jiechu.jsp?time="+new Date().getTime());
	
}

function checkInfo(){
	var u=document.getElementById("username_isdoc").value;
	var p=document.getElementById("password_isdoc").value;
	if(trim(u)=="" || trim(p)==""){
		alert("用户名/密码不能为空");
		return false;
	}
	return true;
	
}

function check_login(){
	var u=document.loginnew.username.value;
	var p=document.loginnew.password.value;
	if(trim(u)=="" || trim(p)==""){
		alert("用户名/密码不能为空");
		return false;
	}
	return true;
	
	
}
function showsub(){
	
	jQuery("#after_login").load("/jsp_cn/weibo/sub_login.jsp?time="+new Date().getTime());
}

function loginout_sd(){
	jQuery("#setwb").load("/jsp_cn/shengda/loginout.jsp?time="+new Date().getTime());
	
}

function tologin(url){
	document.getElementById("ifs").src =url;
	
}


function showsd(){
//    __IBW__.useSDO = true;
//    if(__IBW__.View.loginStatus)
//    {
//        __IBW__.useSDOLogin();
//        __IBW__.useSDO = false;
//    }else{
//        __IBW__.openWidget('login');
//    }
__IBW__ && __IBW__.Connect();

}

function openmsn(){
 window.open('/jsp_cn/msn/call.jsp','new','height='+400+',,innerHeight='+400+',width='+450+',innerWidth='+450+',top='+200+',left='+200+',toolbar=no,menubar=no,scrollbars=auto,resizeable=no,location=no,status=no');
}
function setMSN_News(){
	var num = "0";
	var obj = document.getElementsByName('change');
	for(i=0;i<obj.length;i++){
		if(obj[i].checked){
			num = "1";
			break;
		}
	}
	if(num == "0"){
		alert("至少选择一项操作");
		return;
	}else{
		submitMSN_News();
	}
}
function submitMSN_News(){
	var url = "/jsp_cn/msn/update.jsp?time="+new Date().getTime();
	//var url = "/app/rr/aa?time="+new Date().getTime()+"&fn=setrr";

	if(document.getElementById("change_down").checked){
		url += "&cd=1";
	}
	if(document.getElementById("change_fav").checked){
		url += "&cf=1";
	}
	if(typeof(document.getElementById("change_bbs")) != 'undefined' && document.getElementById("change_bbs") != null && document.getElementById("change_bbs").checked){
		url += "&cb=1";
	}
	if(document.getElementById("change_message").checked){
		url += "&cm=1";
	}
	if(typeof(document.getElementById("change_doudan_fav")) != 'undefined' && document.getElementById("change_doudan_fav") != null && document.getElementById("change_doudan_fav").checked){
		url += "&cdf=1";
	}
	if(typeof(document.getElementById("change_doudan_top")) != 'undefined' && document.getElementById("change_doudan_top") != null && document.getElementById("change_doudan_top").checked){
		url += "&cdt=1";
	}

	jQuery("#setmsn").load(url);
}

function openqq(){
	window.open('/jsp_cn/qq/call.jsp','new','height='+400+',,innerHeight='+400+',width='+450+',innerWidth='+450+',top='+200+',left='+200+',toolbar=no,menubar=no,scrollbars=auto,resizeable=no,location=no,status=no');
	
}

function openrr(url){
	if(url==null || url==''){
		window.open('/jsp_cn/renren/call.jsp','new','height='+450+',,innerHeight='+450+',width='+550+',innerWidth='+550+',top='+200+',left='+200+',toolbar=no,menubar=no,scrollbars=auto,resizeable=no,location=no,status=no');
		return;
	}
  	window.open('/jsp_cn/renren/call.jsp?url='+url,'new','height='+450+',,innerHeight='+450+',width='+550+',innerWidth='+550+',top='+200+',left='+200+',toolbar=no,menubar=no,scrollbars=auto,resizeable=no,location=no,status=no');
}

function openqq_app(){
	window.open('/jsp_cn/qq/call.jsp?appflag=1','new','height='+400+',,innerHeight='+400+',width='+450+',innerWidth='+450+',top='+200+',left='+200+',toolbar=no,menubar=no,scrollbars=auto,resizeable=no,location=no,status=no');
	
}
function setTXQQ_News(){
	var num = "0";
	var obj = document.getElementsByName('change');
	for(i=0;i<obj.length;i++){
		if(obj[i].checked){
			num = "1";
			break;
		}
	}
	if(num == "0"){
		alert("至少选择一项操作");
		return;
	}else{
		submitTXQQ_News();
	}
}
function submitTXQQ_News(){
		var url = "/jsp_cn/qq/update.jsp?time="+new Date().getTime();
		//var url = "/app/rr/aa?time="+new Date().getTime()+"&fn=setrr";
	
		if(document.getElementById("change_down").checked){
			url += "&cd=1";
		}
		if(document.getElementById("change_fav").checked){
			url += "&cf=1";
		}
		if(document.getElementById("change_message").checked){
			url += "&cm=1";
		}
		if(document.getElementById("change_top").checked){
			url += "&ct=1";
		}
		if(typeof(document.getElementById("change_doudan_fav")) != 'undefined' && document.getElementById("change_doudan_fav") != null && document.getElementById("change_doudan_fav").checked){
		url += "&cdf=1";
	}
	if(typeof(document.getElementById("change_doudan_top")) != 'undefined' && document.getElementById("change_doudan_top") != null && document.getElementById("change_doudan_top").checked){
		url += "&cdt=1";
	}
	
	jQuery("#settxqq").load(url);
}
function openmsn_iframe(){
 window.open('/jsp_cn/msn/call.jsp?come=msn','new','height='+370+',,innerHeight='+370+',width='+453+',innerWidth='+453+',top='+200+',left='+200+',toolbar=no,menubar=no,scrollbars=auto,resizeable=no,location=no,status=no');
}

function checkchrom(){
	parent.location.href='http://www.docin.com';
}
function checkchrom_showhidden(){
	parent.location.href='http://www.docin.com?check=1';
	
}
function showhiddenby_msniframe(){
	document.getElementById("newlogin").style.display="none";
	showsub();
}
 function opendx(){
 	window.open('/jsp_cn/zgdx/call.jsp','new','height='+430+',,innerHeight='+430+',width='+500+',innerWidth='+500+',top='+150+',left='+150+',toolbar=no,menubar=no,scrollbars=auto,resizeable=no,location=no,status=no');
 }
 function setZGDX_News(){
	var num = "0";
	var obj = document.getElementsByName('change');
	for(i=0;i<obj.length;i++){
		if(obj[i].checked){
			num = "1";
			break;
		}
	}
	if(num == "0"){
		alert("至少选择一项操作");
		return;
	}else{
		submitZGDX_News();
	}
}
function submitZGDX_News(){
	var url = "/jsp_cn/zgdx/update.jsp?time="+new Date().getTime();
	//var url = "/app/rr/aa?time="+new Date().getTime()+"&fn=setrr";

	if(document.getElementById("change_down").checked){
		url += "&cd=1";
	}
	if(document.getElementById("change_fav").checked){
		url += "&cf=1";
	}
	if(typeof(document.getElementById("change_bbs")) != 'undefined' && document.getElementById("change_bbs") != null && document.getElementById("change_bbs").checked){
		url += "&cb=1";
	}
	if(document.getElementById("change_message").checked){
		url += "&cm=1";
	}
	jQuery("#settxqq").load(url);
}

function openalipay(){
	window.open('/jsp_cn/alipay/call.jsp','new','height='+450+',,innerHeight='+450+',width='+950+',innerWidth='+950+',top='+200+',left='+200+',toolbar=no,menubar=no,scrollbars=auto,resizeable=no,location=no,status=no');
}